    
    TestCase
    (
        'ie.ondevice.objectkit.FunctionImplementTestCase'

    ,   {
            testAnonymousTraitProvider: function () 
            {
                var Subject= function () {};
                Subject.implement
                (
                    new function () 
                    {
                        var floor= Math.floor;
                        
                        this.constructor.implement
                        (
                            {
                                getFloor: function () 
                                {
                                    return floor;
                                }
                            }
                        );    
                    }
                );
                
                var subject= new Subject;
                assertNotNull('subject has a property called getFloor', subject.getFloor);
                assertInstanceOf('subject has the getFloor method', Function, subject.getFloor);
                assertSame('subject.getFloor returns a referecne to Math.floor', Math.floor, subject.getFloor());
            }
            
        ,   testTraitProvider: function () 
            {
                var A= new Function
                ,   B= new Function
                ,   C= new Function
                
                A.implement
                (
                    {
                        aMethod: new Function
                    }
                )   
                
                B.inherit(A).implement
                (
                    {
                        bMethod: new Function
                    }
                );
                
                C.inherit(B).implement
                (
                    {
                        cMethod: new Function
                    }
                );
                
                assertSame('C has aMethod', A.aMethod, C.aMethod);
            }
            
            /**
             * The parent property, like the constructor property, should
             * remain intact after any implementation operation.
             */
        ,   testParentAfterImplement: function () 
            {
                var A= new Function
                ,   B= new Function
                ,   C= new Function
                ,   D= new Function
                
                B.inherit(A);
                C.inherit(B);
                
                assertSame('B is the parent of C', B, C.prototype.parent.constructor);
                assertSame('A is the parent of B', A, B.prototype.parent.constructor);
                
                C.implement(B.prototype);
                
                assertSame('B is the parent of C after mixin', B, C.prototype.parent.constructor);
            }    
            
            
        ,   testConstructorAfterImplement: function () 
            {
                var A= new Function
                ,   B= new Function
                ,   C= new Function
                ,   D= new Function
                
                B.inherit(A);
                C.inherit(B);
                
                assertSame('B is its own constructor', B, B.prototype.constructor);
                assertSame('A is its own constructor', A, A.prototype.constructor);
                
                C.implement(B.prototype);
                
                assertSame('C is its own constructor', C, C.prototype.constructor);
            }   
            
        ,   testPreventOverride: function () 
            {
                var A= new Function
                ,   B= new Function
                ,   C= new Function
                    
                ,   t1= // a traits provider
                    {
                        property: {} // assign a unique object
                    }
                    
                ,   t2= // another traits provider
                    {
                        property: {} // assign a unique object
                    }
                
                A.implement(t1);
                
                assertFalse('Override protection is disabled by default', Function.implement.preventOverride);
                
                // switch protection on- this property is now true for Function.prototype.implement.preventOverride
                A.implement.preventOverride= true;
                assertTrue('Override protection is now enabled', A.implement.preventOverride && Function.prototype.implement.preventOverride);
                
                // attempt to override the 'property' member
                A.implement(t2);
                
                assertSame('The property was not overridden', A.prototype.property, t1.property);
                
                assertFalse('After #implement, preventOverride is reset to false', A.implement.preventOverride);
                
                // override again- as protection is off, this will work
                A.implement(t2);
                
                assertSame('The property was overridden', A.prototype.property, t2.property);
            }
            
        ,   testFunctionDeclarationsAreImplementedByName: function () 
            {
                var A= new Function
                
                ,   m= function method () {}
                ,   v= {}
                
                A.implement(m);
                
                assertSame('The method was added by name', A.prototype.method, m);
                
                A.implement
                (
                    function getValue ()
                    {
                        return v;
                    }
                );
                
                assertInstanceOf('getValue was added by name', Function, A.prototype.getValue);
                assertSame('anotherMethod was implemented', v, new A().getValue())
            }
            
            
        ,   testImplmentInObjectContext: function () 
            {
                if (!window.XMLHttpRequest)
                    XMLHttpRequest= new Function;
                    
                
                    
                XMLHttpRequest.implementStatic= function () 
                {
                    return Function.implementStatic.apply(this, arguments);  
                };
                
                XMLHttpRequest.implement= function () 
                {
                    return Function.implement.apply(this, arguments);
                };    
                    
                var value= {}
                ,   error= null
                ;
                
                try 
                {
                    
                    XMLHttpRequest.implementStatic
                    (
                        {
                            property: value
                        }
                    )
                }
                catch (thrown) 
                {
                    error= thrown;
                }
                
                assertNull('No error should have been thrown adding property to XMLHttpRequest constructor', error);
                assertSame('The property was added to the XMLHttpRequest constructor', XMLHttpRequest.property, value);
                
                assertTrue('The property was deleted from the constructor', delete XMLHttpRequest.property);
                error= null

                try 
                {
                    XMLHttpRequest.implement
                    (
                        {
                            property: value
                        }
                    );
                }
                catch (thrown) 
                {
                    error= thrown;
                }

                assertNull('No error was thrown adding property to XMLHttpRequest.prototype', error);
                assertSame('The property was added to the XMLHttpRequest prototype', XMLHttpRequest.prototype.property, value);
                assertTrue('The property was deleted from the constructor', delete XMLHttpRequest.prototype.property);
            }
        }
    );